
import $app from './$app';//公共方法

import common from './ajax/common';
import login from './ajax/login';
import upload from './ajax/upload';
import libo from './ajax/libo';
import proBig from './ajax/proBig';

const $ajax = {
	//专利提交
	patentSubmit(obj,success){
		$app.postAjax('patent/submit',obj, (res)=>{
			success(res.data);
		});
	},

	//所有业务订单 
	orderAllList(obj,success,fail){

		$app.showLoading = false;
		$app.postAjax('order/all',obj, (res)=>{
			success(res.data);
		}, (res)=>{
			fail instanceof Function && fail();
		});
	},

	//订单详情
	orderInfo(id,success) {
		$app.postAjax('order/info', {
			id
		}, (res) => {
			success(res.data);
		});
	},

	//充值 获取微信支付二维码
	rechargeCode(money,success) {
		$app.showLoading = false;
		$app.postAjax('partner/recharge', {
			money
		}, (res) => {
			success(res.data);
		});
	},

	//支付宝充值
	aliWebPay(id,success) {
		$app.showLoading = false;
		$app.postAjax('order/aliWebPay', {
			id
		}, (res) => {
			success(res.data);
		});
	},

	//订单是否支付完成
	isPayed(id,success) {
		$app.showLoading = false;
		$app.postAjax('order/isPayed', {
			id
		}, res => {
			success(res.data.is_payed);
		});
	},

	//订单使用 余额 + 猫币支付
	mBalancePay(id,use_currency,success){
		$app.postAjax('order/balancePay', {
			//use_currency 0不使用,1使用
			id,use_currency
		}, res => {
			success();
		});
	},
	//商标智能分类 选十项
	cDeCgs(obj,success){
		$app.postAjax('tm/chooseDefaultCgs', obj, res => {
			success(res.data);
		});
	},


	//商标分类获取 1 2 3层级
	mGlistAll(obj,success){

		let fcgparent=obj.fcgparent;//父级ID，根级为0 必填
		let tm_draft_id=obj.tm_draft_id || '';//草稿箱id 选填
		let fcgids=obj.fcgids || '';//搜索功能匹配中的数组

		let fcgRoot=$app.getLocal('fcgRoot');
		let judgeA = (fcgparent==0 && !$app.judgeData(tm_draft_id) && !$app.judgeData(fcgids));

		if(judgeA && $app.judgeData(fcgRoot)){
			success instanceof Function && success(fcgRoot);
		}else{
			$app.postAjax('tm/cgList',obj, res => {
				let resData=res.data;
				
				if(judgeA){
					$app.setLocal(resData,'fcgRoot');//设置本地存储
				}
				success instanceof Function && success(resData);
			});
		}
		
		
	},

	

	//商标委托书下载
	tmAttorney(obj,success){
		$app.postAjax('download/tmAttorney', obj, res => {
			success(res.data);
		});
	},

	//商标提交
	tmSubmit(obj,success){
		$app.postAjax('tm/submit', obj, res => {
			success(res.data);
		});
	},
	
	//美术作品提交
	copyrightMS(obj,success){
		$app.postAjax('copyright/submitWork', obj, res => {
			success(res.data);
		});
	},

	//type:1美术作品委托书/2美术作品权属说明
	workAC(type,people_name,works_name,success){
		let url='';
		if(type==1){
			url="workAttorney";
		}else{
			url="workCertificate";
		}
		$app.postAjax(`download/${url}`, {
			people_name,works_name
		}, res => {
			success(res.data);
		});
	},
	
	//软著登记提交
	copyrightRJ(obj,success){
		$app.postAjax('copyright/submitSoftware', obj, res => {
			success(res.data);
		});
	},

	//购买专利服务
	buyPatentTT(obj,success,fail){
		$app.postAjax('service/buyPatent', obj, res => {
			success(res.data);
		},()=>{
			fail instanceof Function && fail();
		});
	},

	//购买商标服务
	buyTmTT(obj,success,fail){
		$app.postAjax('service/buyTm', obj, res => {
			success(res.data);
		},()=>{
			fail instanceof Function && fail();
		});
	},

	

	//删除订单
	orderDel(order_id,success){
		$app.postAjax('order/del', {
			order_id,
		}, res => {
			$app.toast(res.msg,true);
			success(res.data);
		});
	},
	//补正 OA 提交操作
	patentCo(obj,success){
		$app.postAjax('patent/correct', obj, res => {
			success(res.data);
		});
	},

	//缴申请费/办理登记费
	patPayP(patent_id,type,use_currency,success){
		$app.postAjax('patent/payPatentFee', {
			patent_id,//专利ID
			type,//1余额支付,2自行缴费
			use_currency//0不使用猫币,1使用
		}, res => {
			success(res.data);
		});
	},

	

	//企业信息验证提交
	cpAuth_YZ(obj,success){
		$app.postAjax('partner/companyAuth',obj, res => {
			success();
			$app.toast(res.msg,true);
		});
	},
	
	//版权详情
	copyrightII(order_id,success){
		$app.postAjax('copyright/info', {
			order_id,
			id:''
		}, res => {
			success(res.data);
		});
	},
	

	// 专利：实用新型+版权+外观设计，的，专利申请人历史记录
	peopleTpl(applicant,success){
		$app.showLoading = false;
		$app.postAjax('patent/peopleTpl', {
			applicant
		}, res => {
			success(res.data);
		});
	},


	//专利补差价
	buyGoodsXx(goods_id,num,remark,success){
		$app.postAjax('service/buyGoods', {
			goods_id,num,remark
		}, res => {
			success(res.data);
		});
	},

	//无流程的版权购买
	buyCopyrightZx(goods_id,success){
		$app.postAjax('service/buyCopyright', {
			goods_id
		}, res => {
			success(res.data);
		});
	},

	//绑定银行卡号
	bindBlankXx(blank_name,blank_type,blank_account,blank_username,that,success){
		$app.postAjax('partner/bindBlank', {
			blank_name,blank_type,blank_account,blank_username
		}, res => {
			$app.toast(res.msg,true);
			success();
		},res=>{
			$app.failFocus(res,that);
		});
	},

	//保存头像
	updateHeadImg(path,success){
		$app.postAjax('partner/updateHeadImg', {
			path
		}, res => {
			$app.toast(res.msg,true);
			success();
		});
	},

	//保存开票信息
	yYinvoice(company_title,invoice_number,that,success){
		$app.postAjax('partner/invoice', {
			company_title,invoice_number
		}, res => {
			$app.toast(res.msg,true);
			success();
		},res=>{
			$app.failFocus(res,that);
		});
	},

	//查询商标分类
	searchTmType(obj,success){
		$app.postAjax('tm/searchTmType',obj, res => {
			success(res.data);
		});
	},


	// 服务项目套餐列表
	// 套餐类型：1商标检索,2商标管理,3拓客,4商标分析报告包年,5专利管理,6专利搜索,7专利查重,8混合套餐
	psGoodsList(service_type,success){

		let psGoodsList = $app.getSession('psGoodsList');

		if (!$app.judgeData(service_type) && $app.judgeData(psGoodsList) ) {
			success(psGoodsList);
		} else {
			$app.showLoading = false;//不显示loading

			$app.postAjax('partnerService/goodsList',{
				service_type
			}, res => {
				let resData = res.data;

				!$app.judgeData(service_type) && $app.setSession(resData, 'psGoodsList');//设置本地存储
				success(resData);
			});
		}

		
	},

	//增值服务 生成订单
	psGL_buy(package_id,success){
		$app.postAjax('partnerService/buy',{
			package_id
		}, res => {
			success(res.data);
		});
	},

	//根据订单ID生成微信支付二维码
	wxQrcodePayO(id,success){
		$app.showLoading = false;//不显示loading
		$app.postAjax('order/wxQrcodePay',{id}, res => {
			success(res.data);
		});
	},

	//企业用户消息
	pTmessages(is_read,pageSize, page, success){
		$app.showLoading = false;//不显示loading
		$app.postAjax('partner/messages',{
			is_read,
			pageSize,
			page
		}, res => {
			success(res.data);
		});
	},

	//标记消息已读
	pTreadMsg(msg_id,success){
		$app.showLoading = false;//不显示loading
		$app.postAjax('partner/readMsg',{msg_id}, res => {
			success(res.data)
		});
	},


	//标记全部消息已读
	pTreadMsgAll(success){
		$app.postAjax('partner/readMsgAll',{}, res => {
			success(res.data)
		});
	},


	//获取专利撰写文件
	patentFilesDown(order_id,success){
		$app.showLoading = false;//不显示loading
		$app.postAjax('patentWrite/patentFiles',{
			order_id
		}, res => {
			success(res.data)
		});
	},

	//反馈专利撰写文件是否合格
	patentFilesCheck(id,state,remark,success){
		$app.postAjax('patentWrite/patentCheck',{
			id,state,remark
		}, res => {
			$app.toast('提交成功',true)
			success(res.data)
		});
	},

	//撰写订单 - 添加留言 msg_type:1文字,2图片,3附件
	WriteAddContactLog(order_id,msg_type,message,file_path,success,fail){
		$app.showLoading = false;//不显示loading
		$app.postAjax('Write/addContactLog',{
			order_id,msg_type,message,file_path
		}, res => {
			success(res.data);
		},res=>{
			fail(res.data);
		});
	},

	// 撰写订单 - 获取留言列表
	WriteContactLogs(order_id,success){
		$app.postAjax('Write/contactLogs',{
			// 只显示最近50条
			order_id,pageSize: 50
		}, res => {
			success(res.data)
		});
	},

	// 商标查看补正历史记录
	tm_bzInfo(bz_id,success){
		$app.postAjax('tm/bzInfo',{
			bz_id
		}, res => {
			success(res.data);
		});
	},

	
	

	




	

	

	
	

	


	


	


	
	

	

	

};


// 对象合并
Object.assign($ajax, common, login, upload,libo,proBig);

// 返回在vue模板中的调用接口
export default $ajax 
